<?php
/**
 * @file views-view-fields.tpl.php
 * Default simple view template to all the fields as a row.
 *
 * - $view: The view in use.
 * - $fields: an array of $field objects. Each one contains:
 *   - $field->content: The output of the field.
 *   - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
 *   - $field->class: The safe class id to use.
 *   - $field->handler: The Views field handler object controlling this field. Do not use
 *     var_export to dump this object, as it can't handle the recursion.
 *   - $field->inline: Whether or not the field should be inline.
 *   - $field->inline_html: either div or span based on the above flag.
 *   - $field->wrapper_prefix: A complete wrapper containing the inline_html to use.
 *   - $field->wrapper_suffix: The closing tag for the wrapper.
 *   - $field->separator: an optional separator that may appear before a field.
 *   - $field->label: The wrap label text to use.
 *   - $field->label_html: The full HTML of the label to use including
 *     configured element type.
 * - $row: The raw result object from the query, with all data it fetched.
 *
 * @ingroup views_templates
 */
?>

<?php

$institution   = isset($row->field_field_lending_instituion[0]['rendered']['#markup']) ? $row->field_field_lending_instituion[0]['rendered']['#markup'] : 'n.a.';
$collection    = isset($row->field_field_collection[0]['rendered']['#markup']) ? $row->field_field_collection[0]['rendered']['#markup'] : 'n.a.';
$accession_num = isset($row->field_field_accession_id[0]['rendered']['#markup']) ? $row->field_field_accession_id[0]['rendered']['#markup'] : 'n.a.';
$geography     = isset($row->field_field_origin_location[0]['rendered']['#markup']) ? $row->field_field_origin_location[0]['rendered']['#markup'] : 'n.a.';

$medium = array();
foreach($row->field_field_curatorial_categorization as $key) {
  $medium[] = $key['rendered']['#markup'];
}

$materials = array();
foreach($row->field_field_object_material as $key) {
  $materials[] = $key['rendered']['#markup'];
}

$keywords = array();
foreach($row->field_field_tags as $key) {
  $keywords[] = '<a href="' . url($key['rendered']['#href']) . '">' . $key['rendered']['#title'] . '</a>';
}

?>

<dl>
  <dt>Institution/Collection</dt>
    <dd><?php print $institution; ?> / <?php print $collection; ?></dd>
  <dt>Accession Number</dt>
    <dd><?php print $accession_num; ?></dd>
  <dt>Medium</dt>
    <dd><?php print implode(', ', $medium); ?></dd>
  <dt>Materials</dt>
    <dd><?php print implode(', ', $materials); ?></dd>
  <dt>Geography</dt>
    <dd><?php print $geography; ?></dd>
  <dt>Keywords</dt>
    <dd><?php print implode(', ', $keywords); ?></dd>
</dl>
